import axios from "axios";
const instance = axios.create({
    // baseURL: 'http://192.168.113.249:8081/cms'
    baseURL: "/api",
});

export default instance;
instance.interceptors.request.use(function(config) {
    console.log("请求");
    let token = localStorage.getItem("x-auth-token");
    if (token) {
        config.headers["x-auth-token"] = token
    }
    // config.headers.token = "aaa"
    return config;
}, function(error) {

    return Promise.reject(error);
});

instance.interceptors.response.use(function(response) {
    console.log("响应", response);
    if (response.data.code != 0 && response.data.code != 400 && response.data.code != 407) {
        alert("统一提示:" + response.data.message)
        return;
    }
    return response.data;
    // return "aaaa"
}, function(error) {
    return Promise.reject(error);
});